package cn.tt.tuantuanerp.tuantuanerp.product.webapi.controller;



import cn.tt.tuantuanerp.tuantuanerp.comment.pojo.vo.SkuLogStandardVO;
import cn.tt.tuantuanerp.tuantuanerp.comment.security.LoginPrincipal;
import cn.tt.tuantuanerp.tuantuanerp.comment.web.JsonResult;
import cn.tt.tuantuanerp.tuantuanerp.product.service.ISkuLogService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * 商品日志的controller层
 *
 * @author 大大大威
 * @version 0.0.1
 */
@RestController
@RequestMapping("/skus/log")
@Slf4j
@Api(tags = "2. 商品日志模块")
public class SkuLogController {

    @Autowired
    ISkuLogService skuLogService;



    /**
     * 根据skuId查询日志
     * @return 返回查询结果
     */
    @ApiOperation("查询sku日志列表")
    @ApiOperationSupport(order = 403)
    @GetMapping("/{skuId:[0-9]+}/{pageIndex:[0-9]+}/{pageSize:[0-9]+}")
    public JsonResult<List<SkuLogStandardVO>> list(
                           @PathVariable Long skuId,
                           @PathVariable @RequestParam(required = false,defaultValue = "1") int pageIndex,
                           @PathVariable  @RequestParam(required = false,defaultValue = "20") int pageSize,
                           @ApiIgnore @AuthenticationPrincipal LoginPrincipal loginPrincipal
                           ) {
        log.debug("接收到查询sku日志列表请求");
        System.out.println("pageIndex = " + pageIndex + ", pageSize = " + pageSize + ", loginPrincipal = " + loginPrincipal);
        return JsonResult.ok(skuLogService.list(skuId,pageIndex,pageSize,loginPrincipal));
    }



}
